home *** CD-ROM | disk | FTP | other *** search
- ----------
-
- Listing 2
-
- var
- p1, p2, p3, p4 : ^longint;
- begin
- {*
- * Grab three chunks from the heap.
- *}
- new(p1);
- p1^ := 1;
- new(p2);
- p2^ := 2;
- new(p3);
- p3^ := 3;
- {*
- * Return the second chunk to the heap and grab
- * another.
- *}
- dispose(p2);
- new(p4);
- p4^ := 4;
- {*
- * Whoops! I forgot that I disposed of the second
- * chunk.
- *}
- p2^ := -2;
- {*
- * Now look at the results...
- *}
- writeln('p1^ = ', p1^);
- writeln('p2^ = ', p2^);
- writeln('p3^ = ', p3^);
- writeln('p4^ = ', p4^);
- end.
-
- ----------
-
-